﻿<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">修改房源</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">房源</a>
                </li>
                <li class="breadcrumb-item active">修改房源</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">修改房源信息</h3>
                </div>
                <div class="panel-body"> 
                    <div class="example-wrap">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="panel-body container-fluid">
                                    <div class="row row-lg">

                                        <div class="col-sm-12 col-md-12">
                                            <div class="example-wrap margin-sm-0" id="div_yuanliaomingcheng">
                                                <h4 class="example-title">楼号</h4>
                                                <div class="form-group">
                                                    <input type="text" class="form-control" id="xuegailouhaoshuju" placeholder="所需数量，请填数字" />
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-12 col-md-12">
                                            <div class="example-wrap margin-sm-0">
                                                <h4 class="example-title"></h4>
                                                <div class="form-group" style="margin-top: 28px;">
                                                    <button type="button" class="btn btn-block btn-info" id="btn_tianjia" onclick="XuGai();">修改</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <input type="text" hidden="hidden" id="xiaoquid" />
        <input type="text" hidden="hidden" id="louhaoid" />
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#SpanFangWu").click();
        var xiaoqu = getQuery("xiaoqu");
        var louhao = getQuery("louhao");
        $("#xiaoquid").val(xiaoqu);
        $("#louhaoid").val(louhao);
        $("#xuegailouhaoshuju").val(louhao);
    });


    function XuGai() {
        var xiaoqu = $("#xiaoquid").val();
        var louhao = $("#louhaoid").val();
        var xuegailouhaoshuju = $("#xuegailouhaoshuju").val();
        if (louhao == xuegailouhaoshuju) {
            alert("请更改楼号");
        } else {
            document.getElementById("btn_tianjia").disabled = true; 
            $.ajax({
                type: 'post',
                url: '../FangYuanXinXi/XuGaiLouHao',
                dataType: 'text',
                async: true,
                data: { xiaoqu: xiaoqu, louhao: louhao, xuegailouhaoshuju: xuegailouhaoshuju },
                success: function (result) {
                    if (result == "1") {
                        alert("修改成功");
                        document.getElementById("btn_tianjia").disabled = false; 
                        location.href = "../FangYuanXinXi/FangYuanXinXiList";
                    } else {
                        alert("修改失败");
                    }
                }
            });
        }
    }

    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }


</script>